/**
 * 
 */
package com.shy.portal.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.gson.annotations.Expose;
import com.shy.base.entity.BaseEntity;

/**
 * <p>
 * Title: Manager
 * </p>
 * <p>
 * Description:用户實体类
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author H2013788
 */
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Entity
@Table(name = "portal_user")
public class User extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户名
     */
    @Expose
    @Column(name = "username")
    private String username;

    /**
     * 密码
     */
    @Expose
    @Column(name = "password")
    private String password;
    
    /**
     * 姓名
     */
    @Expose
    @Column(name = "realname")
    private String realname; // 姓名


    /**
     * salt
     */
    @Column(name = "salt")
    private String salt; 
    
    /**
     * 手机
     */
    @Expose
    @Column(name = "phone")
    private String phone; // 手机

    /**
     * 郵件
     */
    @Expose
    @Column(name = "email")
    private String email; // 邮箱
    
    @Column(name = "remark")
    private String remark;

    
    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, orphanRemoval = true)
    @JoinColumn(name = "user_id", referencedColumnName="id")
    private Set<UserRole> userRoles;

    public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
     * @return the salt
     */
    public String getSalt() {
        return salt;
    }

    /**
     * @param salt the salt to set
     */
    public void setSalt(String salt) {
        this.salt = salt;
    }


    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * 
     * @return username + salt
     * @author H2201965
     * @date 2018/2/6下午3:37:04
     */
    public String getCredentialsSalt() {
        return username + salt;
    }


    public Set<UserRole> getUserRoles() {
        return userRoles;
    }

    public void setUserRoles(Set<UserRole> userRoles) {
        this.userRoles = userRoles;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
    

}
